package com.zq.blog_serve.controller;

import com.zq.blog_serve.common.AjaxResult;
import com.zq.blog_serve.service.system.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("login")
    public AjaxResult login(@RequestBody Map map) {
        String userName = map.get("userName").toString();
        String pwd = map.get("pwd").toString();
        // 生成令牌
        String token = loginService.login(userName, pwd);
        return AjaxResult.success(token);
    }

}
